<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>JavaScript第九课</title>
    <script src="../JavaScript_Lesson16/js/jquery-3.4.1.min.js"></script>

</head>

<body>
    <form id="test-form" action="#0" onsubmit="return che();">
        <p><label>Name: <input name="name" value="字">字</label></p>
        <p><label>Email: <input name="email"></label></p>
        <p><label>Password: <input name="password" type="password"></label></p>
        <p>Gender: <label><input name="gender" type="radio" value="m" checked> Male</label> <label><input name="gender"
                    type="radio" value="f"> Female</label></p>
        <p><label>City: <select name="city">
                    <option value="BJ" selected>Beijing</option>
                    <option value="SH">Shanghai</option>
                    <option value="CD">Chengdu</option>
                    <option value="XM">Xiamen</option>
                </select></label></p>
        <p><button type="submit">Submit</button></p>
    </form>

    <script src="js/js.js"></script>
    <script>
        function che() {
            var name = $("input[name=name]").val();
            var email = $("input[name=email]").val();
            var password = $("input[name=password]").val();
            var gender = $("input[name=gender]:checked").val();
            var City = $("select[name=city]").val();

            var SB = {
                name: name,
                email: email,
                password: password,
                gender: gender,
                City: City
            }
            console.log(JSON.stringify(SB));
            return false;
        }
    </script>

</body>

</html>